#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>

using namespace std;
using LL = long long;
using PII = pair<int, int>;

const int N = 110;

int n, m;
int ne[N];

int main(){
#ifdef LOCALFLAG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m;
    for(int i = 0; i < n; i ++) ne[i] = i + 1;
    ne[n] = 1;

    int p = 0;
    for(int i = 1; i <= n; i ++){
        for(int j = 1; j < m; j ++){
            p = ne[p];
        }
        cout << ne[p] << " ";
        ne[p] = ne[ne[p]];
    }


    return 0;
}